package com.woniu.humanresource.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.humanresource.entity.PurchaseList;
import com.woniu.humanresource.service.PurchaseListService;
import com.woniu.humanresource.dao.PurchaseListMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author xiang
* @description 针对表【purchaselist】的数据库操作Service实现
* @createDate 2022-07-12 19:44:23
*/
@Service
public class PurchaseListServiceImpl extends ServiceImpl<PurchaseListMapper, PurchaseList>
    implements PurchaseListService{

    @Autowired
    PurchaseListMapper purchaseListMapper;

    //插入采购清单表
    @Override
    public void addPurchaseList(PurchaseList[] purchases) {

        for(int i=0;i<purchases.length;i++){
            purchases[i].setStatus(1);//设置状态为1：待入库
            purchaseListMapper.insert(purchases[i]);
        }
    }

    //根据pid查询
    @Override
    public List<PurchaseList> getPurchaseListByPid(int purchaseid) {
        //查询条件
        QueryWrapper<PurchaseList> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("purchaselist_pid", purchaseid);

        //去查询
        List<PurchaseList> purchaseLists = purchaseListMapper.selectList(queryWrapper);

        return purchaseLists;
    }
}




